package com.github.ylt.protocol.http.server.exchange;

import com.github.ylt.protocol.http.Headers;
import com.github.ylt.protocol.http.HttpContext;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.net.URI;

public class HttpExchangeImpl extends HttpExchange{

    private Exchange exchange;

    public HttpExchangeImpl(Exchange exchange){
        this.exchange = exchange;
    }
    @Override
    public URI getRequestURL() {
        return exchange.getUri();
    }

    @Override
    public String getMethod() {
        return exchange.getMethod();
    }

    @Override
    public Headers getHeaders() {
        return null;
    }

    @Override
    public Headers getRequestHeaders() {
        return exchange.getRequestHeaders();
    }

    @Override
    public Headers getResponseHeaders() {
        return exchange.getResponseHeaders();
    }

    @Override
    public String getFullRequestURL() {
        return "";
    }

    @Override
    public HttpContext getContext() {
        return exchange.getContext();
    }

    @Override
    public void close() {

    }

    @Override
    public InputStream getRequestBody() {
        return exchange.getRequestBody();
    }

    @Override
    public OutputStream getResponseBody() {
        return null;
    }

    @Override
    public void sendResponse(String message) throws IOException {
        exchange.sendResponse(message);
    }

    @Override
    public void setResponseCode(int code) {
        exchange.setResponseCode(code);
    }

    @Override
    public InetSocketAddress getRemoteAddress() {
        return exchange.getRemoteAddress();
    }

    @Override
    public int getResponseCode() {
        return exchange.getResponseCode();
    }

    @Override
    public InetSocketAddress getLocalAddress() {
        return exchange.getLocalAddress();
    }

    @Override
    public String getProtocol() {
        return exchange.getProtocol();
    }

    @Override
    public Object getAttribute(String name) {
        return null;
    }

    @Override
    public void setAttribute(String name, Object value) {

    }

    @Override
    public void setStreams(InputStream i, OutputStream o) {

    }

    @Override
    public boolean isHeadRequest() {
        return exchange.isHeadRequest();
    }

    @Override
    public boolean isGetRequest() {
        return exchange.isGetRequest();
    }

    @Override
    public boolean isPostRequest() {
        return exchange.isPostRequest();
    }

    @Override
    public boolean isPutRequest() {
        return exchange.isPutRequest();
    }

    @Override
    public boolean isDeleteRequest() {
        return exchange.isDeleteRequest();
    }

    @Override
    public boolean isNotifyRequest() {
        return exchange.isNotifyRequest();
    }

    @Override
    public boolean isSubscribeRequest() {
        return exchange.isSubscribeRequest();
    }

    @Override
    public boolean isUnsubscribeRequest() {
        return exchange.isUnsubscribeRequest();
    }

    @Override
    public boolean isSOAPRequest() {
        return exchange.getRequestHeaders().containsKey("SOAPACTION");
    }

    @Override
    public String getAction() {
        return exchange.getRequestHeaders().get("SOAPACTION").getFirst();
    }

    public Exchange getExchange(){
        return exchange;
    }

}
